function [newZ] = readCommand

filename = '../data/finalData/command';
load('triangles.mat');
load('gridStructure.mat');

Z = readCurrentSequence('../data/finalData/current.sequence');

fid = fopen(filename);

line = fgetl(fid);

while ischar(line)
	if numel(line)==0
		line=fgetl(fid);
		continue;
	end

	if line(1)=='A' % add
        temp = sscanf(line(5:end), '%d %d %d %d %f %f %f', [1 7]);
        newZ = onFlyAdd(temp(1)+1,temp(2), temp(3)+1, temp(5), temp(6), temp(7), Z, sites, triangles, gridStructure);
        
	elseif line(1)=='D' %delete
		temp = sscanf(line(5:end), '%d %d %d %d',[1,4]);
        newZ = onFlyDelete(temp(1)+1,temp(2),temp(3)+1, Z, sites, triangles, gridStructure);
	end
	line=fgetl(fid);	
end

fclose(fid);
end